﻿// -----------------------------------------------------------------------
// <copyright file="TableOwnRowsAccessRight.cs" company="JSC Centido">
//  Copyright (c) JSC Centido. All rights reserved.
// </copyright>
// -----------------------------------------------------------------------

using System;

namespace Centido.Core
{
    /// <summary>
    ///   A table own rows access right.
    /// </summary>
    public class TableOwnRowsAccessRight : ITableAccessRight
    {
        /// <summary>
        ///   The access type
        /// </summary>
        private readonly DataAction _dataAction;

        /// <summary>
        ///   The target table.
        /// </summary>
        private readonly Table _table;

        /// <summary>
        ///   The target user.
        /// </summary>
        private readonly User _user;


        /// <summary>
        ///   Creates a new instance of the <see cref="TableOwnRowsAccessRight"/> class.
        /// </summary>
        /// <param name="table">The target table.</param>
        /// <param name="user">The target user</param>
        /// <param name="dataAction">The data action.</param>
        /// <exception cref="ArgumentNullException">Thrown when the value of <paramref name="table"/> is null.</exception>
        /// <exception cref="ArgumentNullException">Thrown when the value of <paramref name="user"/> is null.</exception>
        internal TableOwnRowsAccessRight(Table table, User user, DataAction dataAction)
        {
            if (table == null)
                throw new ArgumentNullException("table");
            if (user == null)
                throw new ArgumentNullException("user");

            _table = table;
            _user = user;
            _dataAction = dataAction;
        }


        /// <summary>
        ///   Gets the user that has an access right.
        /// </summary>
        public User User
        {
            get { return _user; }
        }


        /// <summary>
        ///   Gets the table.
        /// </summary>
        public Table Table
        {
            get { return _table; }
        }


        /// <summary>
        ///   Gets the granted data action.
        /// </summary>
        public DataAction DataAction
        {
            get { return _dataAction; }
        }
    }
}
